package com.woniu.liuzhougov.systemSettings.controller;

import com.woniu.liuzhougov.itemAndTask.pojo.Area;
import com.woniu.liuzhougov.itemAndTask.service.AreaService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class AreaController {

    @Resource
    private AreaService areaService;

    //全部查询
    @RequiresPermissions("area_selAll")
    @RequestMapping("/area/selAll")
    @ResponseBody
    public Map selAll() {
        List<Area> list = areaService.selAll();
        Map<String, Object> map = new HashMap<>();
        map.put("count", list.size());
        map.put("data", list);
        map.put("code", 0);
        map.put("msg", "");
        return map;
    }

    //添加
    @RequiresPermissions("area_insert")
    @RequestMapping("/area/insert")
    @ResponseBody
    public String insert(Area area){
        return  areaService.insert(area);
    }

    //修改
    @RequiresPermissions("area_update")
    @RequestMapping("/area/update")
    @ResponseBody
    public String update(Area area){
        return  areaService.update(area);
    }

    //删除
    @RequiresPermissions("area_delete")
    @RequestMapping("/area/delete")
    @ResponseBody
    public String delete(int areaId){
        System.out.println(areaId);
        return  areaService.delete(areaId);
    }
}
